package com.wangsd.common.component.extBean;

import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;

@Data
@XStreamAlias("xml")
public class WxPayOrderQueryResultExt extends BaseWxPayResult {
    @XStreamAlias("promotion_detail")
    private String promotionDetail;
    @XStreamAlias("device_info")
    private String deviceInfo;
    @XStreamAlias("openid")
    private String openid;
    @XStreamAlias("is_subscribe")
    private String isSubscribe;
    @XStreamAlias("trade_type")
    private String tradeType;
    @XStreamAlias("trade_state")
    private String tradeState;
    @XStreamAlias("bank_type")
    private String bankType;
    @XStreamAlias("total_fee")
    private Integer totalFee;
    @XStreamAlias("settlement_total_fee")
    private Integer settlementTotalFee;
    @XStreamAlias("fee_type")
    private String feeType;
    @XStreamAlias("cash_fee")
    private Integer cashFee;
    @XStreamAlias("cash_fee_type")
    private String cashFeeType;
    @XStreamAlias("coupon_fee")
    private Integer couponFee;
    @XStreamAlias("coupon_count")
    private Integer couponCount;
    @XStreamAlias("transaction_id")
    private String transactionId;
    @XStreamAlias("out_trade_no")
    private String outTradeNo;
    @XStreamAlias("attach")
    private String attach;
    @XStreamAlias("time_end")
    private String timeEnd;
    @XStreamAlias("trade_state_desc")
    private String tradeStateDesc;
    @XStreamAlias("sub_openid")
    private String subOpenid;
    @XStreamAlias("sub_is_subscribe")
    private String subIsSubscribe;

    public static WxPayOrderQueryResultExt fromXML(String xmlString) {
        XStream xstream = XStreamInitializer.getInstance();
        xstream.allowTypesByWildcard(new String[]{"me.chanjar.weixin.**",
                "cn.binarywang.wx.**", "com.github.binarywang.**",
                "com.wangsd.common.component.**"});
        xstream.processAnnotations(WxPayOrderQueryResultExt.class);
        WxPayOrderQueryResultExt result = (WxPayOrderQueryResultExt) xstream.fromXML(xmlString);
        result.setXmlString(xmlString);
        return result;
    }
}
